<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>动态登录注册切换</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            color: #333;
            overflow: hidden;
        }

        .container {
            position: relative;
            width: 800px;
            height: 500px;
            background-color: white;
            border-radius: 20px;
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
            overflow: hidden;
        }

        .form-container {
            position: absolute;
            top: 0;
            height: 100%;
            width: 50%;
            transition: all 0.6s ease-in-out;
            padding: 50px;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }

        .login-container {
            left: 0;
            z-index: 2;
        }

        .register-container {
            left: 50%;
            z-index: 1;
        }

        h1 {
            font-size: 28px;
            margin-bottom: 30px;
            color: #444;
        }

        .input-group {
            position: relative;
            margin-bottom: 25px;
        }

        input {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 16px;
            transition: all 0.3s;
        }

        input:focus {
            outline: none;
            border-color: #667eea;
            box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
        }

        label {
            position: absolute;
            left: 15px;
            top: 12px;
            color: #777;
            font-size: 16px;
            transition: all 0.3s;
            pointer-events: none;
        }

        input:focus + label,
        input:not(:placeholder-shown) + label {
            top: -10px;
            left: 10px;
            font-size: 12px;
            background-color: white;
            padding: 0 5px;
            color: #667eea;
        }

        button {
            background: linear-gradient(to right, #667eea, #764ba2);
            color: white;
            border: none;
            padding: 12px;
            border-radius: 5px;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s;
            margin-top: 10px;
        }

        button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .toggle-container {
            position: absolute;
            top: 0;
            left: 50%;
            width: 50%;
            height: 100%;
            overflow: hidden;
            transition: all 0.6s ease-in-out;
            z-index: 10;
        }

        .toggle {
            position: relative;
            width: 200%;
            height: 100%;
            left: -100%;
            transition: all 0.6s ease-in-out;
        }

        .toggle-panel {
            position: absolute;
            width: 50%;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 0 40px;
            text-align: center;
            top: 0;
            transition: all 0.6s ease-in-out;
        }

        .toggle-left {
            left: 0;
            background: linear-gradient(to right, #764ba2, #667eea);
            color: white;
        }

        .toggle-right {
            left: 50%;
            background: linear-gradient(to right, #667eea, #764ba2);
            color: white;
        }

        .toggle-panel h1 {
            color: white;
        }

        .toggle-panel p {
            margin-bottom: 20px;
            font-size: 14px;
        }

        .ghost {
            background-color: transparent;
            border: 1px solid white;
        }

        .ghost:hover {
            background-color: white;
            color: #667eea;
        }

        .social-icons {
            margin-top: 20px;
            display: flex;
            gap: 15px;
        }

        .social-icons a {
            color: white;
            font-size: 20px;
            transition: all 0.3s;
        }

        .social-icons a:hover {
            transform: translateY(-3px);
        }
    </style>
</head>
<body>
<div class="container">
    <div class="form-container login-container">
        <form action="#">
            <h1>欢迎回来</h1>
            <div class="input-group">
                <input type="email" id="loginEmail" placeholder=" ">
                <label for="loginEmail">邮箱</label>
            </div>
            <div class="input-group">
                <input type="password" id="loginPassword" placeholder=" ">
                <label for="loginPassword">密码</label>
            </div>
            <a href="#" style="display: block; text-align: right; font-size: 14px; color: #667eea; margin-bottom: 20px;">忘记密码?</a>
            <button type="submit">登录</button>
        </form>
    </div>

    <div class="form-container register-container">
        <form action="#">
            <h1>创建账号</h1>
            <div class="input-group">
                <input type="text" id="registerName" placeholder=" ">
                <label for="registerName">用户名</label>
            </div>
            <div class="input-group">
                <input type="email" id="registerEmail" placeholder=" ">
                <label for="registerEmail">邮箱</label>
            </div>
            <div class="input-group">
                <input type="password" id="registerPassword" placeholder=" ">
                <label for="registerPassword">密码</label>
            </div>
            <button type="submit">注册</button>
        </form>
    </div>

    <div class="toggle-container">
        <div class="toggle">
            <div class="toggle-panel toggle-left">
                <h1>你好，朋友!</h1>
                <p>输入您的个人信息，开始与我们同行</p>
                <button class="ghost" id="register">注册</button>
                <div class="social-icons">
                    <a href="#"><i class="fab fa-facebook-f"></i></a>
                    <a href="#"><i class="fab fa-google"></i></a>
                    <a href="#"><i class="fab fa-twitter"></i></a>
                </div>
            </div>
            <div class="toggle-panel toggle-right">
                <h1>欢迎回来!</h1>
                <p>请使用您的账号登录</p>
                <button class="ghost" id="login">登录</button>
                <div class="social-icons">
                    <a href="#"><i class="fab fa-facebook-f"></i></a>
                    <a href="#"><i class="fab fa-google"></i></a>
                    <a href="#"><i class="fab fa-twitter"></i></a>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.4/gsap.min.js"></script>
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
<script>
    document.addEventListener('DOMContentLoaded', function() {
        const loginBtn = document.getElementById('login');
        const registerBtn = document.getElementById('register');
        const container = document.querySelector('.container');
        const loginContainer = document.querySelector('.login-container');
        const registerContainer = document.querySelector('.register-container');
        const toggleContainer = document.querySelector('.toggle-container');
        const toggle = document.querySelector('.toggle');
        const overlay = document.querySelector('.overlay');

        // 初始状态
        let isLoginActive = true;

        // 注册按钮点击事件
        registerBtn.addEventListener('click', () => {
            if (!isLoginActive) return;

            isLoginActive = false;

            // GSAP动画
            gsap.to(loginContainer, { x: '100%', duration: 0.6, ease: "power2.inOut" });
            gsap.to(registerContainer, { x: '-100%', duration: 0.6, ease: "power2.inOut" });
            gsap.to(toggleContainer, { x: '-100%', duration: 0.6, ease: "power2.inOut" });
            gsap.to(toggle, { x: '50%', duration: 0.6, ease: "power2.inOut" });
        });

        // 登录按钮点击事件
        loginBtn.addEventListener('click', () => {
            if (isLoginActive) return;

            isLoginActive = true;

            // GSAP动画
            gsap.to(loginContainer, { x: '0%', duration: 0.6, ease: "power2.inOut" });
            gsap.to(registerContainer, { x: '0%', duration: 0.6, ease: "power2.inOut" });
            gsap.to(toggleContainer, { x: '0%', duration: 0.6, ease: "power2.inOut" });
            gsap.to(toggle, { x: '0%', duration: 0.6, ease: "power2.inOut" });
        });

        // 添加输入框动画
        const inputs = document.querySelectorAll('input');
        inputs.forEach(input => {
            input.addEventListener('focus', function() {
                const label = this.nextElementSibling;
                gsap.to(label, {
                    top: -10,
                    left: 10,
                    fontSize: '12px',
                    color: '#667eea',
                    duration: 0.3,
                    ease: "power2.out"
                });
            });

            input.addEventListener('blur', function() {
                if (this.value === '') {
                    const label = this.nextElementSibling;
                    gsap.to(label, {
                        top: 12,
                        left: 15,
                        fontSize: '16px',
                        color: '#777',
                        duration: 0.3,
                        ease: "power2.out"
                    });
                }
            });
        });

        // 按钮悬停效果
        const buttons = document.querySelectorAll('button:not(.ghost)');
        buttons.forEach(button => {
            button.addEventListener('mouseenter', function() {
                gsap.to(this, {
                    y: -2,
                    boxShadow: '0 5px 15px rgba(0, 0, 0, 0.1)',
                    duration: 0.3
                });
            });

            button.addEventListener('mouseleave', function() {
                gsap.to(this, {
                    y: 0,
                    boxShadow: 'none',
                    duration: 0.3
                });
            });
        });

        // 幽灵按钮悬停效果
        const ghostButtons = document.querySelectorAll('.ghost');
        ghostButtons.forEach(button => {
            button.addEventListener('mouseenter', function() {
                gsap.to(this, {
                    backgroundColor: 'white',
                    color: '#667eea',
                    duration: 0.3
                });
            });

            button.addEventListener('mouseleave', function() {
                gsap.to(this, {
                    backgroundColor: 'transparent',
                    color: 'white',
                    duration: 0.3
                });
            });
        });

        // 社交图标动画
        const socialIcons = document.querySelectorAll('.social-icons a');
        socialIcons.forEach(icon => {
            icon.addEventListener('mouseenter', function() {
                gsap.to(this, {
                    y: -3,
                    duration: 0.3
                });
            });

            icon.addEventListener('mouseleave', function() {
                gsap.to(this, {
                    y: 0,
                    duration: 0.3
                });
            });
        });
    });
</script>
</body>
</html>